
import com.anhdt.dao.MyServletJspOrEjb;
import com.anhdt.model.Menu;
import com.anhdt.vo.TopicVO;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MenuService extends BaseService {

    @Override
    public void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, SQLException {
        response.setContentType("application/json;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            Menu menu = Menu.getInstance();
            List<TopicVO> list = menu.getMenu();
            out.println(this.ResponseJSon(list));
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            exeMethod(request, response);
        } catch (Exception e) {
            System.out.println("Error!");
        }
    }

    protected void show(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            out.println("hello!");
        }
    }

    protected void test(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException {
        response.setContentType("text/xml;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            Menu menu = Menu.getInstance();
            List<TopicVO> list = menu.getMenu();
            out.println(this.ResponseXML(list));
        }
    }
    
    protected void getX() throws Exception{
        MyServletJspOrEjb test = new MyServletJspOrEjb();
        test.doSomething();
    }

}
